
<html lang=""><head>
    <title>模板消息 · MINA</title>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
    <meta name="description" content="">
    <meta name="generator" content="GitBook 3.2.0">




    <link rel="stylesheet" href="../../gitbook/style.css">




    <link rel="stylesheet" href="../../gitbook/gitbook-plugin-highlight/website.css">



    <link rel="stylesheet" href="../../gitbook/gitbook-plugin-search/search.css">























    <meta name="HandheldFriendly" content="true">
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../../gitbook/images/favicon.ico" type="image/x-icon">


    <link rel="next" href="../devtools/devtools.html">


    <link rel="prev" href="api-pay.html">


</head>
<body>

<div class="book with-summary">
    <div>

        <div class="sub_nav_box">
            <div class="sub_nav_inner">




                <ul class="top_sub_nav">




                    <li class="sub_nav_item " data-level="1.1" data-path="../">

                        <a href="../">


                            简易教程

                        </a>

                    </li>

                    <li class="sub_nav_item " data-level="1.2" data-path="../framework/MINA.html">

                        <a href="../framework/MINA.html">


                            框架

                        </a>

                    </li>

                    <li class="sub_nav_item " data-level="1.3" data-path="../component/">

                        <a href="../component/">


                            组件

                        </a>

                    </li>

                    <li class="sub_nav_item selected" data-level="1.4" data-path="./">

                        <a href="./">


                            API

                        </a>

                    </li>

                    <li class="sub_nav_item " data-level="1.5" data-path="../devtools/devtools.html">

                        <a href="../devtools/devtools.html">


                            工具

                        </a>

                    </li>

                    <li class="sub_nav_item " data-level="1.6" data-path="../qa/qa.html">

                        <a href="../qa/qa.html">


                            Q&amp;A

                        </a>

                    </li>




                </ul>




                <!-- <h1>模板消息</h1> -->
                <div id="book-search-input" role="search">
                    <form>
                        <label for="search-input" class="search-icon" id="js-search-icon"></label>
                        <input type="text" id="search-input" name="search-input" placeholder="搜索">
                        <button type="reset" class="clear-input-btn"></button>
                    </form>
                </div>
            </div>
        </div>

        <div class="book-summary">


            <nav role="navigation">





                <ul class="summary">


                    <li class="chapter  open" data-level="1.4.1" data-path="api-network.html">

                        <a href="api-network.html">


                            网络

                        </a>



                        <ul class="articles">


                            <li class="chapter  " data-level="1.4.1.1" data-path="network-request.html">

                                <a href="network-request.html">


                                    发起请求

                                </a>



                            </li>

                            <li class="chapter  " data-level="1.4.1.2" data-path="network-file.html">

                                <a href="network-file.html">


                                    上传、下载

                                </a>



                                <ul class="articles">


                                    <li class="chapter  " data-level="1.4.1.2.1" data-path="network-file.html">

                                        <a href="network-file.html#wxuploadfileobject">


                                            wx.uploadFile

                                        </a>



                                    </li>

                                    <li class="chapter  " data-level="1.4.1.2.2" data-path="network-file.html">

                                        <a href="network-file.html#wxdownloadfileobject">


                                            wx.downloadFile

                                        </a>



                                    </li>


                                </ul>

                            </li>

                            <li class="chapter  " data-level="1.4.1.3" data-path="network-socket.html">

                                <a href="network-socket.html">


                                    WebSocket

                                </a>



                                <ul class="articles">


                                    <li class="chapter  " data-level="1.4.1.3.1" data-path="network-socket.html">

                                        <a href="network-socket.html#wxconnectsocketobject">


                                            wx.connectSocket

                                        </a>



                                    </li>

                                    <li class="chapter  " data-level="1.4.1.3.2" data-path="network-socket.html">

                                        <a href="network-socket.html#wxonsocketopencallback">


                                            wx.onSocketOpen

                                        </a>



                                    </li>

                                    <li class="chapter  " data-level="1.4.1.3.3" data-path="network-socket.html">

                                        <a href="network-socket.html#wxonsocketerrorcallback">


                                            wx.onSocketError

                                        </a>



                                    </li>

                                    <li class="chapter  " data-level="1.4.1.3.4" data-path="network-socket.html">

                                        <a href="network-socket.html#wxsendsocketmessageobject">


                                            wx.sendSocketMessage

                                        </a>



                                    </li>

                                    <li class="chapter  " data-level="1.4.1.3.5" data-path="network-socket.html">

                                        <a href="network-socket.html#wxonsocketmessagecallback">


                                            wx.onSocketMessage

                                        </a>



                                    </li>

                                    <li class="chapter  " data-level="1.4.1.3.6" data-path="network-socket.html">

                                        <a href="network-socket.html#wxclosesocket">


                                            wx.closeSocket

                                        </a>



                                    </li>

                                    <li class="chapter  " data-level="1.4.1.3.7" data-path="network-socket.html">

                                        <a href="network-socket.html#wxonsocketclosecallback">


                                            wx.onSocketClose

                                        </a>



                                    </li>


                                </ul>

                            </li>


                        </ul>

                    </li>

                    <li class="chapter  open" data-level="1.4.2" data-path="media-picture.html">

                        <a href="media-picture.html">


                            媒体

                        </a>



                        <ul class="articles">


                            <li class="chapter  " data-level="1.4.2.1" data-path="media-picture.html">

                                <a href="media-picture.html">


                                    图片

                                </a>



                                <ul class="articles">


                                    <li class="chapter  " data-level="1.4.2.1.1" data-path="media-picture.html">

                                        <a href="media-picture.html#wxchooseimageobject">


                                            wx.chooseImage

                                        </a>



                                    </li>

                                    <li class="chapter  " data-level="1.4.2.1.2" data-path="media-picture.html">

                                        <a href="media-picture.html#wxpreviewimageobject">


                                            wx.previewImage

                                        </a>



                                    </li>


                                </ul>

                            </li>

                            <li class="chapter  " data-level="1.4.2.2" data-path="media-record.html">

                                <a href="media-record.html">


                                    录音

                                </a>



                                <ul class="articles">


                                    <li class="chapter  " data-level="1.4.2.2.1" data-path="media-record.html">

                                        <a href="media-record.html#wxstartrecordobject">


                                            wx.startRecord

                                        </a>



                                    </li>

                                    <li class="chapter  " data-level="1.4.2.2.2" data-path="media-record.html">

                                        <a href="media-record.html#wxstoprecord">


                                            wx.stopRecord

                                        </a>



                                    </li>


                                </ul>

                            </li>

                            <li class="chapter  " data-level="1.4.2.3" data-path="media-voice.html">

                                <a href="media-voice.html">


                                    音频播放控制

                                </a>



                                <ul class="articles">


                                    <li class="chapter  " data-level="1.4.2.3.1" data-path="media-voice.html">

                                        <a href="media-voice.html#wxplayvoiceobject">


                                            wx.playVoice

                                        </a>



                                    </li>

                                    <li class="chapter  " data-level="1.4.2.3.2" data-path="media-voice.html">

                                        <a href="media-voice.html#wxpausevoice">


                                            wx.pauseVoice

                                        </a>



                                    </li>

                                    <li class="chapter  " data-level="1.4.2.3.3" data-path="media-voice.html">

                                        <a href="media-voice.html#wxstopvoice">


                                            wx.stopVoice

                                        </a>



                                    </li>


                                </ul>

                            </li>

                            <li class="chapter  " data-level="1.4.2.4" data-path="media-background-audio.html">

                                <a href="media-background-audio.html">


                                    音乐播放控制

                                </a>



                                <ul class="articles">


                                    <li class="chapter  " data-level="1.4.2.4.1" data-path="media-background-audio.html">

                                        <a href="media-background-audio.html#wxgetbackgroundaudioplayerstateobject">


                                            wx.getBackgroundAudioPlayerState

                                        </a>



                                    </li>

                                    <li class="chapter  " data-level="1.4.2.4.2" data-path="media-background-audio.html">

                                        <a href="media-background-audio.html#wxplaybackgroundaudioobject">


                                            wx.playBackgroundAudio

                                        </a>



                                    </li>

                                    <li class="chapter  " data-level="1.4.2.4.3" data-path="media-background-audio.html">

                                        <a href="media-background-audio.html#wxpausebackgroundaudio">


                                            wx.pauseBackgroundAudio

                                        </a>



                                    </li>

                                    <li class="chapter  " data-level="1.4.2.4.4" data-path="media-background-audio.html">

                                        <a href="media-background-audio.html#wxseekbackgroundaudioobject">


                                            wx.seekBackgroundAudio

                                        </a>



                                    </li>

                                    <li class="chapter  " data-level="1.4.2.4.5" data-path="media-background-audio.html">

                                        <a href="media-background-audio.html#wxstopbackgroundaudio">


                                            wx.stopBackgroundAudio

                                        </a>



                                    </li>

                                    <li class="chapter  " data-level="1.4.2.4.6" data-path="media-background-audio.html">

                                        <a href="media-background-audio.html#wxonbackgroundaudioplaycallback">


                                            wx.onBackgroundAudioPlay

                                        </a>



                                    </li>

                                    <li class="chapter  " data-level="1.4.2.4.7" data-path="media-background-audio.html">

                                        <a href="media-background-audio.html#wxonbackgroundaudiopausecallback">


                                            wx.onBackgroundAudioPause

                                        </a>



                                    </li>

                                    <li class="chapter  " data-level="1.4.2.4.8" data-path="media-background-audio.html">

                                        <a href="media-background-audio.html#wxonbackgroundaudiostopcallback">


                                            wx.onBackgroundAudioStop

                                        </a>



                                    </li>


                                </ul>

                            </li>

                            <li class="chapter  " data-level="1.4.2.5" data-path="file.html">

                                <a href="file.html">


                                    文件

                                </a>



                            </li>

                            <li class="chapter  " data-level="1.4.2.6" data-path="media-video.html">

                                <a href="media-video.html">


                                    视频

                                </a>



                            </li>


                        </ul>

                    </li>

                    <li class="chapter  open" data-level="1.4.3" data-path="data.html">

                        <a href="data.html">


                            数据

                        </a>



                        <ul class="articles">


                            <li class="chapter  " data-level="1.4.3.1" data-path="data.html">

                                <a href="data.html">


                                    数据缓存

                                </a>



                                <ul class="articles">


                                    <li class="chapter  " data-level="1.4.3.1.1" data-path="data.html">

                                        <a href="data.html#wxsetstorageobject">


                                            wx.setStorage

                                        </a>



                                    </li>

                                    <li class="chapter  " data-level="1.4.3.1.2" data-path="data.html">

                                        <a href="data.html#wxsetstoragesynckeyvalue">


                                            wx.setStorageSync

                                        </a>



                                    </li>

                                    <li class="chapter  " data-level="1.4.3.1.3" data-path="data.html">

                                        <a href="data.html#wxgetstorageobject">


                                            wx.getStorage

                                        </a>



                                    </li>

                                    <li class="chapter  " data-level="1.4.3.1.4" data-path="data.html">

                                        <a href="data.html#wxgetstoragesynckey">


                                            wx.getStorageSync

                                        </a>



                                    </li>

                                    <li class="chapter  " data-level="1.4.3.1.5" data-path="data.html">

                                        <a href="data.html#wxclearstorage">


                                            wx.clearStorage

                                        </a>



                                    </li>

                                    <li class="chapter  " data-level="1.4.3.1.6" data-path="data.html">

                                        <a href="data.html#wxclearstoragesync">


                                            wx.clearStorageSync

                                        </a>



                                    </li>


                                </ul>

                            </li>


                        </ul>

                    </li>

                    <li class="chapter  open" data-level="1.4.4" data-path="location.html">

                        <a href="location.html">


                            位置

                        </a>



                        <ul class="articles">


                            <li class="chapter  " data-level="1.4.4.1" data-path="location.html">

                                <a href="location.html#wxgetlocationobject">


                                    获取位置

                                </a>



                            </li>

                            <li class="chapter  " data-level="1.4.4.2" data-path="location.html">

                                <a href="location.html#wxopenlocationobject">


                                    查看位置

                                </a>



                            </li>


                        </ul>

                    </li>

                    <li class="chapter  open" data-level="1.4.5" data-path="device.html">

                        <a href="device.html">


                            设备

                        </a>



                        <ul class="articles">


                            <li class="chapter  " data-level="1.4.5.1" data-path="device.html">

                                <a href="device.html#wxgetnetworktypeobject">


                                    网络状态

                                </a>



                            </li>

                            <li class="chapter  " data-level="1.4.5.2" data-path="device.html">

                                <a href="device.html#wxgetsysteminfoobject">


                                    系统信息

                                </a>



                            </li>

                            <li class="chapter  " data-level="1.4.5.3" data-path="device.html">

                                <a href="device.html#wxonaccelerometerchangecallback">


                                    重力感应

                                </a>



                            </li>

                            <li class="chapter  " data-level="1.4.5.4" data-path="device.html">

                                <a href="device.html#wxoncompasschangecallback">


                                    罗盘

                                </a>



                            </li>


                        </ul>

                    </li>

                    <li class="chapter  open" data-level="1.4.6" data-path="ui.html">

                        <a href="ui.html">


                            界面

                        </a>



                        <ul class="articles">


                            <li class="chapter  " data-level="1.4.6.1" data-path="ui.html">

                                <a href="ui.html">


                                    设置导航条

                                </a>



                            </li>

                            <li class="chapter  " data-level="1.4.6.2" data-path="ui-navigate.html">

                                <a href="ui-navigate.html">


                                    导航

                                </a>



                            </li>

                            <li class="chapter  " data-level="1.4.6.3" data-path="api-animation.html">

                                <a href="api-animation.html">


                                    动画

                                </a>



                            </li>

                            <li class="chapter  " data-level="1.4.6.4" data-path="api-canvas.html">

                                <a href="api-canvas.html">


                                    绘图

                                </a>



                            </li>

                            <li class="chapter  " data-level="1.4.6.5" data-path="ui-other.html">

                                <a href="ui-other.html">


                                    其他

                                </a>



                            </li>


                        </ul>

                    </li>

                    <li class="chapter  open" data-level="1.4.7" data-path="api-login.html">

                        <a href="api-login.html">


                            开放接口

                        </a>



                        <ul class="articles">


                            <li class="chapter  " data-level="1.4.7.1" data-path="api-login.html">

                                <a href="api-login.html">


                                    登录

                                </a>



                                <ul class="articles">


                                    <li class="chapter  " data-level="1.4.7.1.1" data-path="signature.html">

                                        <a href="signature.html">


                                            签名加密

                                        </a>



                                    </li>


                                </ul>

                            </li>

                            <li class="chapter  " data-level="1.4.7.2" data-path="open.html">

                                <a href="open.html">


                                    用户信息

                                </a>



                            </li>

                            <li class="chapter  " data-level="1.4.7.3" data-path="api-pay.html">

                                <a href="api-pay.html">


                                    微信支付

                                </a>



                            </li>

                            <li class="chapter active " data-level="1.4.7.4" data-path="notice.html">

                                <a href="notice.html">


                                    模板消息

                                </a>



                                <ul class="articles">


                                    <li class="chapter  " data-level="1.4.7.4.1" data-path="notice.html">

                                        <a href="notice.html#使用说明">


                                            使用说明

                                        </a>



                                    </li>

                                    <li class="chapter  " data-level="1.4.7.4.2" data-path="notice.html">

                                        <a href="notice.html#接口说明">


                                            接口说明

                                        </a>



                                    </li>


                                </ul>

                            </li>


                        </ul>

                    </li>


                </ul>


            </nav>


        </div>

        <div class="book-body">

            <div class="body-inner">

                <!--                     
                
                <div class="book-header" role="navigation">
                    
                </div>
                
                
                 -->

                <div class="page-wrapper" tabindex="-1" role="main">
                    <div class="page-inner">

                        <div id="book-search-results">
                            <div class="search-noresults">

                                <section class="normal markdown-section">

                                    <p>基于微信的通知渠道，我们为开发者提供了可以高效触达用户的模板消息能力，以便实现服务的闭环并提供更佳的体验。</p><p>模板推送位置：服务通知</p><p>模板下发条件：用户本人在微信体系内与页面有交互行为后触发，详见<a href="#下发条件说明">下发条件说明</a></p><p>模板跳转能力：点击查看详情仅能跳转下发模板的该帐号的各个页面</p><h2 id="使用说明">使用说明</h2><ol><li>获取模板id
                                </li></ol>
                                    <p>​ 登录<a href="https://mp.weixin.qq.com/" target="_blank">https://mp.weixin.qq.com</a>获取模板，如果没有合适的模板，可以申请添加新模板，审核通过后可使用，详见<a href="#审核说明">模板审核说明</a></p><p><img src="./mp-notice.png"></p><ol><li><p>页面的<a href="../wxml/component/form.md"><code>&lt;form/&gt;</code></a>组件，属性<code>report-submit</code>为<code>true</code>时，可以声明为需发模板消息，此时点击按钮提交表单可以获取<code>formId</code>，用于发送模板消息。或者当用户完成<a href="api-pay.html">支付行为</a>，可以获取<code>prepay_id</code>用于发送模板消息。</p></li>
                                    <li><p>调用接口下发模板消息（详见<a href="#接口说明">接口说明</a>）</p></li></ol>
                                    <h2 id="接口说明">接口说明</h2><h3 id="1-获取accesstoken">1. 获取access_token</h3><p>​    access_token是全局唯一接口调用凭据，开发者调用各接口时都需使用access_token，请妥善保存。access_token的存储至少要保留512个字符空间。access_token的有效期目前为2个小时，需定时刷新，重复获取将导致上次获取的access_token失效。</p><p>公众平台的API调用所需的access_token的使用及生成方式说明：</p><ol><li>为了保密appsecrect，第三方需要一个access_token获取和刷新的中控服务器。而其他业务逻辑服务器所使用的access_token均来自于该中控服务器，不应该各自去刷新，否则会造成access_token覆盖而影响业务；
                                </li>
                                    <li>目前access_token的有效期通过返回的expire_in来传达，目前是7200秒之内的值。中控服务器需要根据这个有效时间提前去刷新新access_token。在刷新过程中，中控服务器对外输出的依然是老access_token，此时公众平台后台会保证在刷新短时间内，新老access_token都可用，这保证了第三方业务的平滑过渡；
                                    </li>
                                    <li>access_token的有效时间可能会在未来有调整，所以中控服务器不仅需要内部定时主动刷新，还需要提供被动刷新access_token的接口，这样便于业务服务器在API调用获知access_token已超时的情况下，可以触发access_token的刷新流程。
                                    </li></ol>
                                    <p>​    开发者可以使用AppID和AppSecret调用本接口来获取access_token。AppID和AppSecret可登录微信公众平台官网-设置-开发设置中获得（需要已经绑定成为开发者，且帐号没有异常状态）。AppSecret生成后请自行保存，因为在公众平台每次生成查看都会导致AppSecret被重置。注意调用所有微信接口时均需使用https协议。如果第三方不使用中控服务器，而是选择各个业务逻辑点各自去刷新access_token，那么就可能会产生冲突，导致服务不稳定。</p><p><strong>接口地址：</strong></p><pre><code>https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&amp;appid=APPID&amp;secret=APPSECRET</code></pre>
                                    <p><strong>HTTP请求方式:</strong></p><pre><code>GET</code></pre>
                                    <p><strong>参数说明 :</strong></p><table>
                                    <thead>
                                    <tr><th>参数</th>
                                        <th>必填</th>
                                        <th>说明</th>
                                    </tr></thead><tbody>
                                <tr><td>grant_type</td>
                                    <td>是</td>
                                    <td>获取access_token填写client_credential</td>
                                </tr><tr><td>appid</td>
                                    <td>是</td>
                                    <td>第三方用户唯一凭证</td>
                                </tr><tr><td>secret</td>
                                    <td>是</td>
                                    <td>第三方用户唯一凭证密钥，即appsecret</td>
                                </tr></tbody></table>

                                    <p><strong>返回参数说明：</strong></p><p>正常情况下，微信会返回下述JSON数据包给开发者：</p><pre><code class="lang-json">{<span class="hljs-string">"access_token"</span>:<span class="hljs-string">"ACCESS_TOKEN"</span>,<span class="hljs-string">"expires_in"</span>:<span class="hljs-number">7200</span>}</code></pre>
                                    <table>
                                        <thead>
                                        <tr><th>参数</th>
                                            <th>说明</th>
                                        </tr></thead><tbody>
                                    <tr><td>access_token</td>
                                        <td>获取到的凭证</td>
                                    </tr><tr><td>expires_in</td>
                                        <td>凭证有效时间，单位：秒</td>
                                    </tr></tbody></table>

                                    <p>错误时微信会返回错误码等信息，JSON数据包示例如下（该示例为AppID无效错误）:</p><pre><code class="lang-json">{<span class="hljs-string">"errcode"</span>:<span class="hljs-number">40013</span>,<span class="hljs-string">"errmsg"</span>:<span class="hljs-string">"invalid appid"</span>}</code></pre>
                                    <h3 id="2-发送模板消息">2. 发送模板消息</h3><p><strong>接口地址：(ACCESS_TOKEN需换成上文获取到的access_token)</strong></p><pre><code>https://api.weixin.qq.com/cgi-bin/message/wxopen/template/send?access_token=ACCESS_TOKEN</code></pre>
                                    <p><strong>HTTP请求方式：</strong></p><pre><code>POST</code></pre>
                                    <p><strong>POST参数说明：</strong></p><table>
                                    <thead>
                                    <tr><th>参数</th>
                                        <th>必填</th>
                                        <th>说明</th>
                                    </tr></thead><tbody>
                                <tr><td>touser</td>
                                    <td>是</td>
                                    <td>接收者（用户）的openid</td>
                                </tr><tr><td>template_id</td>
                                    <td>是</td>
                                    <td>所需下发的模板消息的id</td>
                                </tr><tr><td>page</td>
                                    <td>否</td>
                                    <td>点击模板查看详情跳转页面，不填则模板无跳转</td>
                                </tr><tr><td>form_id</td>
                                    <td>是</td>
                                    <td>表单提交场景下，为submit事件带上的<a href="../wxml/component/form.md">formId</a>；支付场景下，为本次支付的<a href="api-pay.html">prepay_id</a></td>
                                </tr><tr><td>value</td>
                                    <td>是</td>
                                    <td>模板内容，不填则下发空模板</td>
                                </tr><tr><td>color</td>
                                    <td>否</td>
                                    <td>模板内容字体的颜色，不填默认黑色</td>
                                </tr><tr><td>emphasis_keyword</td>
                                    <td>否</td>
                                    <td>模板需要放大的关键词，不填则默认无放大</td>
                                </tr></tbody></table>

                                    <p><strong>示例：</strong></p><pre><code class="lang-json">{
  <span class="hljs-string">"touser"</span>: <span class="hljs-string">"OPENID"</span>,  
  <span class="hljs-string">"template_id"</span>: <span class="hljs-string">"TEMPLATE_ID"</span>, 
  <span class="hljs-string">"page"</span>: <span class="hljs-string">"index"</span>,          
  <span class="hljs-string">"form_id"</span>: <span class="hljs-string">"FORMID"</span>,         
  <span class="hljs-string">"data"</span>: {
      <span class="hljs-string">"keyword1"</span>: {
          <span class="hljs-string">"value"</span>: <span class="hljs-string">"339208499"</span>, 
          <span class="hljs-string">"color"</span>: <span class="hljs-string">"#173177"</span>
      }, 
      <span class="hljs-string">"keyword2"</span>: {
          <span class="hljs-string">"value"</span>: <span class="hljs-string">"2015年01月05日 12:30"</span>, 
          <span class="hljs-string">"color"</span>: <span class="hljs-string">"#173177"</span>
      }, 
      <span class="hljs-string">"keyword3"</span>: {
          <span class="hljs-string">"value"</span>: <span class="hljs-string">"粤海喜来登酒店"</span>, 
          <span class="hljs-string">"color"</span>: <span class="hljs-string">"#173177"</span>
      } , 
      <span class="hljs-string">"keyword4"</span>: {
          <span class="hljs-string">"value"</span>: <span class="hljs-string">"广州市天河区天河路208号"</span>, 
          <span class="hljs-string">"color"</span>: <span class="hljs-string">"#173177"</span>
      } 
  },
  <span class="hljs-string">"emphasis_keyword"</span>: <span class="hljs-string">"keyword1.DATA"</span> 
}</code></pre>
                                    <p><strong>返回码说明：</strong></p><p>在调用模板消息接口后，会返回JSON数据包。</p><p>正常时的返回JSON数据包示例：</p><pre><code class="lang-json">{
  <span class="hljs-string">"errcode"</span>:<span class="hljs-number">0</span>,
  <span class="hljs-string">"errmsg"</span>:<span class="hljs-string">"ok"</span>,
}</code></pre>
                                    <p>错误时会返回错误码信息，说明如下：</p><table>
                                    <thead>
                                    <tr><th>返回码</th>
                                        <th>说明</th>
                                    </tr></thead><tbody>
                                <tr><td>40037</td>
                                    <td>template_id不正确</td>
                                </tr><tr><td>41028</td>
                                    <td>form_id不正确，或者过期</td>
                                </tr><tr><td>41029</td>
                                    <td>form_id已被使用</td>
                                </tr><tr><td>41030</td>
                                    <td>page不正确</td>
                                </tr></tbody></table>

                                    <p><strong>使用效果：</strong></p><p><img src="../image/notice.png"></p><p><strong>注意：内部测试阶段，模板消息下发后，在客户端仅能看到由“公众号安全助手”下发的简单通知。能收到该提示，即表明模板消息功能已经调试成功。待该功能正式上线后，将可以展示成上图效果。</strong></p><h3 id="下发条件说明">下发条件说明</h3><ol><li><p>支付</p><p>当用户在小程序内完成过支付行为，可允许开发者向用户在7天内推送有限条数的模板消息（1次支付可下发1条，多次支付下发条数独立，互相不影响）</p></li>
                                    <li><p>提交表单</p><p>当用户在小程序内发生过提交<a href="wxml/component/form.md">表单</a>行为且该表单声明为要发模板消息的，开发者需要向用户提供服务时，可允许开发者向用户在7天内推送有限条数的模板消息（1次提交表单可下发1条，多次提交下发条数独立，相互不影响）</p></li></ol>
                                    <h2 id="审核说明">审核说明</h2><h3 id="1标题">1.标题</h3><p>1.1标题不能存在相同</p><p>1.2标题意思不能存在过度相似</p><p>1.3标题必须以“提醒”或“通知”结尾</p><p>1.4标题不能带特殊符号、个性化字词等没有行业通用性的内容</p><p>1.5标题必须能体现具体服务场景</p><p>1.6标题不能涉及营销相关内容，包括不限于：</p><p>​    消费优惠类、购物返利类、商品更新类、优惠券类、代金券类、红包类、会员卡类、积分类、活动类等营销倾向通知</p><h3 id="2关键词">2.关键词</h3><p>2.1同一标题下，关键词不能存在相同</p><p>2.2同一标题下，关键词不能存在过度相似</p><p>2.3关键词不能带特殊符号、个性化字词等没有行业通用性的内容</p><p>2.4关键词内容示例必须与关键词对应匹配</p><p>2.5关键词不能太过宽泛，需要具有限制性，例如：“内容”这个就太宽泛，不能审核通过</p><h2 id="违规说明">违规说明</h2><p>除不能违反运营规范外，还不能违反以下规则，包括但不限于：</p><ol><li>不允许恶意诱导用户进行触发操作，以达到可向用户下发模板目的
                                </li>
                                    <li>不允许恶意骚扰，下发对用户造成骚扰的模板
                                    </li>
                                    <li>不允许恶意营销，下发营销目的模板
                                    </li>
                                    <li><p>不允许通过服务号下发模板来告知用户在小程序内触发的服务相关内容</p><h2 id="处罚说明">处罚说明</h2></li></ol>
                                    <p>根据违规情况给予相应梯度的处罚，一般处罚规则如下：</p><p>第一次违规，删除违规模板以示警告，</p><p>第二次违规，封禁接口7天，</p><p>第三次违规，封禁接口30天，</p><p>第四次违规，永久封禁接口</p><p>处罚结果及原因以站内信形式告知</p>

                                </section>

                            </div>
                            <div class="search-results">
                                <div class="has-results">

                                    <h1 class="search-results-title"><span class="search-results-count"></span> 个结果 "<span class="search-query"></span>"</h1>
                                    <ul class="search-results-list"></ul>

                                </div>
                                <div class="no-results">

                                    <h1 class="search-results-title">没有找到相关内容 "<span class="search-query"></span>"</h1>

                                </div>
                            </div>
                        </div>

                    </div>
                </div>
                <div class="foot" id="footer">
                    <ul class="links ft">
                        <li class="links_item"><a href="">关于腾讯</a></li>
                        <li class="links_item"><a href="">服务协议</a></li>
                        <li class="links_item"><a href="">运营规范</a></li>
                        <li class="links_item"><a href="">辟谣中心</a></li>
                        <li class="links_item"><a href="">客服中心</a></li>
                        <li class="links_item"><a href="">联系邮箱</a></li>
                        <li class="links_item"><a href="">侵权投诉</a></li>
                        <li class="links_item">
                            <p class="copyright">Copyright © 2012-<span id="s_copyright_year"></span> Tencent. All Rights Reserved.</p>
                        </li>
                    </ul>
                </div>

            </div>



            <a href="api-pay.html" class="navigation navigation-prev " aria-label="Previous page: 微信支付">
                <i class="fa fa-angle-left"></i>
            </a>


            <a href="../devtools/devtools.html" class="navigation navigation-next " aria-label="Next page: 工具">
                <i class="fa fa-angle-right"></i>
            </a>



        </div>
    </div>


    <script src="../../gitbook/gitbook.js"></script>
    <script src="../../gitbook/theme.js"></script>


    <script src="../../gitbook/gitbook-plugin-search/search-engine.js"></script>



    <script src="../../gitbook/gitbook-plugin-search/search.js"></script>



    <script src="../../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>



    <script src="../../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>


   




</div></body></html>